#include "GlassShatterInclude.hlsli"

[maxvertexcount(4)]
void main(
	point GlassShatterInputGS input[1], 
	inout TriangleStream< GlassShatterInputPS > output
)
{
	GlassShatterInputPS element = (GlassShatterInputPS)0;

	float4 pos = input[0].Position;
	pos.z += translationAmount * (1.0f - (time / fadeOutTime));
	
	float4x4 wvp = mul(mul(world, view), projection);
	float2 texCoord = input[0].TexCoords;
	element.Position = mul(pos, wvp);
	element.WorldNormal = mul(input[0].Normal, (float3x3)world);
	element.WorldPosition = mul(input[0].Position.xyz, (float3x3)world);
	element.TexCoords = texCoord;
	output.Append(element);

	element.Position = mul(pos + float4(0.0, 0.2, 0, 0), wvp);
	element.TexCoords = texCoord + float2(0.0f, 64.0f / 512.0f);
	output.Append(element);

	element.Position = mul(pos + float4(0.2, 0.0, 0, 0), wvp);
	element.TexCoords = texCoord + float2(64.0f / 512.0f, 0.0f);
	output.Append(element);

	element.Position = mul(pos + float4(0.2, 0.2, 0, 0), wvp);
	element.TexCoords = texCoord + float2(64.0f / 512.0f, 64.0f / 512.0f);
	output.Append(element);
}